<template>
  <div>
    <a-form :form="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
      <a-form-item label="模型名称">
        <a-input v-decorator="['name']" disabled />
      </a-form-item>
      <a-form-item label="申请理由">
        <a-textarea
          v-decorator="['applyReasons', { rules: [{ required: true, message: '请输入申请理由' }] }]"
          placeholder="请输入申请理由"
          :rows="4"
        />
      </a-form-item>
    </a-form>
  </div>
</template>

<script>
import { applyApproval } from '@/api/manage'

export default {
  name: 'AuditModel',
  props: {
    currentDetailRecord: {
      type: Object,
      default: () => {},
    },
    applyType: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      form: this.$form.createForm(this),
    }
  },
  mounted() {
    this.$nextTick(() => {
      console.log(this.applyType)
      this.form.setFieldsValue({
        name: this.currentDetailRecord.name,
      })
    })
  },
  methods: {
    handleSubmit() {
      this.form.validateFields((err, values) => {
        if (err) {
          return
        }
        applyApproval({
          modelUuid: this.currentDetailRecord.uuid,
          version: this.currentDetailRecord.version,
          applyReasons: values.applyReasons,
          applyType: this.applyType,
        }).then((res) => {
          if (res.code === 200) {
            this.$message.success(res.message)
            this.handleCancel()
          } else {
            this.$message.error(res.message)
          }
        })
      })
    },
    handleCancel() {
      this.$emit('close')
    },
  },
}
</script>
<style lang="less" scoped></style>
